package br.com.pb.bymychef.persistencia.bean;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name="tb_perfil")
@SequenceGenerator(name = "S_TB_PERFIL", sequenceName = "S_TB_PERFIL", initialValue = 0, allocationSize = 1)
public class Perfil {
    
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "S_TB_PERFIL")
    @Column(name = "idPerfil")
    private Long idPerfil;
    @Column(name="descricao", nullable=false, length=150)
    private String descricao;
    @OneToMany(mappedBy="perfil")
    private List<Usuario> usuarios = new ArrayList<Usuario>();
    
    public Perfil() {
	
    }
    
    public Perfil(String descricao, List<Usuario> usuarios) {
	super();
	this.descricao = descricao;
	this.usuarios = usuarios;
    }

    public Long getIdPerfil() {
        return idPerfil;
    }
    public void setIdPerfil(Long idPerfil) {
        this.idPerfil = idPerfil;
    }
    public String getDescricao() {
        return descricao;
    }
    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    @Override
    public int hashCode() {
	final int prime = 31;
	int result = 1;
	result = prime * result
		+ ((idPerfil == null) ? 0 : idPerfil.hashCode());
	return result;
    }

    @Override
    public boolean equals(Object obj) {
	if (this == obj)
	    return true;
	if (obj == null)
	    return false;
	if (getClass() != obj.getClass())
	    return false;
	Perfil other = (Perfil) obj;
	if (idPerfil == null) {
	    if (other.idPerfil != null)
		return false;
	} else if (!idPerfil.equals(other.idPerfil))
	    return false;
	return true;
    }
    
}
